package com.cgnpc.scp.run.controller;

import com.cgnpc.cud.annotation.OperatorType;
import com.cgnpc.cud.annotation.UBA;
import com.cgnpc.cud.core.domain.AjaxResult;
import com.cgnpc.scp.common.utils.AjaxResultUtil;
import com.cgnpc.scp.run.mybatis.entity.MarketReview;
import com.cgnpc.scp.run.service.MarketReviewService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**********************************
 * 用途说明: 市场机会评审
 * 作者姓名: zhangyibing
 * 创建时间: 2020年9月13日15:51:35
 ***********************************/
@RestController
@RequestMapping("/run/marketReview")
public class MarketReviewController {
    private static final Logger LOGGER = LoggerFactory.getLogger(MarketInfoController.class);

    @Autowired
    private MarketReviewService marketReviewService;

    @Autowired
    private MessageSource messageSource;

    /**********************************
     * 用途说明: 保存市场机会评审信息
     * 参数说明 subject
     * 返回值说明:
     ***********************************/
    @ApiOperation(value="保存市场机会评审信息")
    @UBA(module = "调试经营管理", action = "保存机会评审", channel = OperatorType.Button)
    @RequestMapping(value = "/saveOrUpdateReview", method = {RequestMethod.POST})
    public AjaxResult saveOrUpdateReview(HttpServletRequest request, @RequestBody MarketReview review) {
        try {
            return marketReviewService.saveOrUpdateReview(review);
        } catch (Exception e) {
            LOGGER.error("MarketReviewController saveOrUpdateReview error : {}",e.getMessage(),e);
            return AjaxResultUtil.createI18nDefaultError(request,messageSource,e.getMessage());
        }
    }

}
